<?php

namespace App\Http\Controllers;

use App\Http\Service\SearchService;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;
use App\Http\Service\ViewcountService;
use Illuminate\Support\Facades\DB;

class SearchController extends BaseController
{
    private $getRules=[
            'type'=> 'required',
            //'city_code'=>'required',
        ];
    private  $getRulesMessage=[
            'type.required'=> 'type不能为空',
           // 'city_code.required'=> 'city_code不能为空',

        ];
    public $repository;
    public $historyservice;
    public function __construct(SearchService $repository)
    {
        parent::__construct();
        $this->repository = $repository;
    }

   //全站搜索
    public function getList(Request $request)
    {
        $data=[
            'content'=>$request->json("content"),
            'unit_type'=>$request->json("unit_type"),
            'platform_name'=>$request->json("platform_name"),//平台名称
            'brand_name'=>$request->json("brand_name"),//品牌名称
            'people_id'=>$request->json("people_id"),//用户id
            'page'=>$request->json("page"),
            'limit'=>$request->json("limit"),
            'type'=>$request->json("type"),

        ];
        $data['content'] = addslashes($data['content']); // 简单转义特殊字符

        //dd($data);
        $this->success($this->repository->getList($request,$data));
    }
    //搜索详情
    public function dataDetail(Request $request)
    {
        $data=[
            'unique_id'=>$request->json("unique_id"),
            'people_id'=>$request->json("people_id"),
        ];
        $this->success($this->repository->dataDetail($request,$data));
    }

}
